<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue-2.5.21.js"></script>
    <style>
        .shuangpin {
            height: 70px;
            padding: 10px;
        }
        
        .clear {
            float: right;
            margin-right: 10px;
        }
        
        .shuangpin>img {
            float: left;
        }
        
        #foot {
            position: fixed;
            bottom: 0;
            background-color: grey;
            width: 100%;
        }
        
        .money {
            display: inline-block;
            font-size: 20px;
        }
        
        .js {
            float: right;
            padding: 10px 5px;
            background-color: aqua;
            margin-right: 10px;
        }
        
        .zhanwei {
            text-align: center;
        }
    </style>
</head>

<body>
    <div id="car">
        <span class="yxsp">已选商品</span> <button class="clear" @click="claear">清空</button>
        <div class="shuangpin" v-for="(item,index) in mylist">
            <img :src="item[0]" alt="">
            <p>{{item[1]}}</p>
            <span>{{item[2]}}</span> <button @click="jj(item,index)">-</button> {{item[3]}} <button @click="add(item,index)">+</button>
            <div id="foot">
                <span>商品总量：{{item[3]}}</span><br>
                <span class="money">￥528</span>
                <!-- <span class="add">另需配送费35元</span> -->
                <button class="js"><去结算</button>
            </div>
            <div class="zhanwei" v-show="mylist.length == 0">
                购物车空空如也，快去逛逛吧！
            </div>
        </div>

    </div>
</body>

</html>
<script>
    var vm = new Vue({
        el: "#car",
        data: {
            mylist: [
                ["./虾.png", "秋刀鱼/斤", "35.00", 2],
                ["./鱼.png", "鲜大带鱼/条", "45.00", 4],
                ["./皮皮虾.png", "鲜活全母皮皮虾/斤", "85.00", 3],
                ["./虾.png", "鲜大带鱼/条", "45.00", 2],

            ]
        },
        methods: {
            jj(item, index) {

                Vue.set(item[3]--);
                // console.log(this.mylist[index][3]);
                // item[index]--;
            },
            add(item, index) {
                Vue.set(item[3]++);
                // item[index] / 1 + 1;
                // console.log(this.mylist[index][3]);
            },
            claear() {
                this.mylist = [];
            }
        },
    })
</script>